<template>
  <div id="app">
    <button @click="getGoodList">获取商品列表</button>
    <button @click="addGoodList">添加商品列表</button>
    <button @click="getGoodsById(8)">根据id获取商品信息</button>
  </div>
</template>

<script>
export default {
  name: "app",
  methods: {
    async getGoodList() {
      let res1 = await this.$http.get("/api/goodslist")
      console.log(res1.data.data)
    },

    async addGoodList() {
      const { data } = await this.$http.post("/api/addgoods", {
        name: "玻璃",
        price: 8,
        count: 1001,
        img: "图片"
      })
      console.log(data)
    },
    async getGoodsById(val) {
      const { data } = await this.$http.get(`/api/getgoods/${val}`)
      console.log("data", data)
    }
  }
}
</script>

<style></style>
